const path = require('path');
const config = {
  projectName: 'myApp',
  date: '2021-3-3',
  designWidth: 750,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2
  },
  sourceRoot: 'src',
  outputRoot: 'dist',
  plugins: [],
  alias: {
    '@components': path.resolve(__dirname, '..', 'src/components'),
    '@api': path.resolve(__dirname, '..', 'src/api'),
    '@assets': path.resolve(__dirname, '..', 'src/assets'),
    '@core': path.resolve(__dirname, '..', 'src/core'),
    '@config': path.resolve(__dirname, '..', 'src/config'),
    '@pages': path.resolve(__dirname, '..', 'src/pages'),
    '@styles': path.resolve(__dirname, '..', 'src/styles'),
    '@utils': path.resolve(__dirname, '..', 'src/utils'),
    '@': path.resolve(__dirname, '..', 'src'),
  },
  defineConstants: {
  },
  copy: {
    patterns: [
      {
        from: 'src/components/vant/wxs/',
        to: 'dist/components/vant/wxs/',
      },
      {
        from: 'src/components/vant/common/style/',
        to: 'dist/components/vant/common/style/',
      },
      {
        from: 'src/components/vant/common/index.wxss',
        to: 'dist/components/vant/common/index.wxss',
      },
      {
        from: 'src/components/vant/sticky/index.wxs',
        to: 'dist/components/vant/sticky/index.wxs',
      },
      {
        from: 'src/components/vant/tabs/index.wxs',
        to: 'dist/components/vant/tabs/index.wxs',
      },
      {
        from: 'src/components/vant/checkbox/index.wxs',
        to: 'dist/components/vant/checkbox/index.wxs',
      },
      {
        from: 'src/components/vant/field/index.wxs',
        to: 'dist/components/vant/field/index.wxs',
      },
      {
        from: 'src/components/vant/picker-column/index.wxs',
        to: 'dist/components/vant/picker-column/index.wxs',
      },
      {
        from: 'src/components/vant/dialog/index.wxss',
        to: 'dist/components/vant/dialog/index.wxss',
      },
      {
        from: 'src/components/vant/tree-select/index.wxs',
        to: 'dist/components/vant/tree-select/index.wxs',
      },
      {
        from: 'src/components/vant/area/index.wxs',
        to: 'dist/components/vant/area/index.wxs',
      },
      {
        from: 'src/components/vant/button/index.wxs',
        to: 'dist/components/vant/button/index.wxs',
      },
      {
        from: 'src/components/vant/grid-item/index.wxs',
        to: 'dist/components/vant/grid-item/index.wxs',
      },
      {
        from: 'src/components/vant/grid/index.wxs',
        to: 'dist/components/vant/grid/index.wxs',
      },
      {
        from: 'src/components/vant/icon/index.wxs',
        to: 'dist/components/vant/icon/index.wxs',
      },
      {
        from: 'src/components/vant/image/index.wxs',
        to: 'dist/components/vant/image/index.wxs',
      },
      {
        from: 'src/components/vant/nav-bar/index.wxs',
        to: 'dist/components/vant/nav-bar/index.wxs',
      },
      {
        from: 'src/components/vant/popup/index.wxs',
        to: 'dist/components/vant/popup/index.wxs',
      },
      {
        from: 'src/components/vant/cell',
        to: 'dist/components/vant/cell',
      },
      {
        from: 'src/components/vant',
        to: 'dist/components/vant',
      },
    ],
    options: {
    }
  },
  framework: 'vue',
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {
          selectorBlackList: [/^.van-.*?$/],
        },
      },
      url: {
        enable: true,
        config: {
          limit: 1024 // 设定转换尺寸上限
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  },
  h5: {
    publicPath: '/',
    staticDirectory: 'static',
    postcss: {
      autoprefixer: {
        enable: true,
        config: {
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  }
}

module.exports = function (merge) {
  if (process.env.NODE_ENV === 'development') {
    return merge({}, config, require('./dev'))
  }
  return merge({}, config, require('./prod'))
}
